#include "mainscene.h"
#include "ui_mainscene.h"
#include <QPainter>

MainScene::MainScene(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainScene)
{
    ui->setupUi(this);

    //主场景的基本配置

    //设置标题
    this->setWindowTitle("翻金币主场景");
    //设置固定大小
    this->setFixedSize(640, 1176);
    //设置图标
    this->setWindowIcon(QIcon(":/image/resource/image/Coin0001.png"));

//    connect(ui->actionQuit, &QAction::triggered, [=](){
//        this->close();
//    });

    //开始按钮
    MyPushButton * startButton = new MyPushButton(":/image/resource/image/MenuSceneStartButton.png");
    startButton->move(this->width() * 0.5 - startButton->width() * 0.5, this->height() * 0.8);
    startButton->setParent(this);
}

MainScene::~MainScene()
{
    delete ui;
}

//利用绘图事件 绘制背景
void MainScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pixmap;
    pixmap.load(":/image/resource/image/PlayLevelSceneBg.png");
    painter.drawPixmap(0, 0, this->width(), this->height(), pixmap);

    //价值标题
    pixmap.load(":/image/resource/image/Title.png");

    pixmap = pixmap.scaled(pixmap.width() * 0.5, pixmap.height() * 0.5);

    painter.drawPixmap(20, 60, pixmap.width() * 2, pixmap.height() * 2, pixmap);


}

void MainScene::on_actionQuit_triggered()
{
    this->close();
}
